var app = getApp();
Page({
  data: {
    info:{
      title: '北京佩姐老火锅（南中环店）',
      address: '山西省太原市长治路123号',
      renshu: '1位',
      riqi:'2020年12月31日 周一 下午18:30',
      shijian:'下午18:30',
      name:'向东流',
      mobile:'18235143012',
      beizhu:'包间最好靠窗户，但要环境幽静一些，所有菜辣椒都要少放，少盐，少油。',
      baojian: '大厅'
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var order_id = options.order_id
    this.setData({
      order_id:order_id
    })
    this.getYdzwOrderInfo();
  },

  /**
   * 获取订单列表
   */
  getYdzwOrderInfo: function () {
    let _this = this;
    app.visit('account/getYdzwOrderInfo', {
      order_id:_this.data.order_id
    }, '',function (result) {
      console.log("订单列表", result);
      _this.setData({
        info:result.data
      });
    });
  },

  /**
   * 获取打赏信息
   */
  getReward: function () {
    let _this = this;
    app.visit('drinker/getReward', {}, '',function (result) {
      console.log("打赏", result);
      _this.setData({
        reward:result.data
      });
    });
  },

  jmds:function(){
    wx.requestSubscribeMessage({
      tmplIds: ['9yn1U7g0rMXUNY_jcrhqBYSuO7GOQ654oMsvdYNaev8'],
      success (res) {

      }
    })
    var t = this
    var ds_price = t.data.reward.price;
    wx.showModal({
      title: '提示',
      content: '确认打赏酒妹吗',
      success: function (res) {
        if (res.confirm) {//这里是点击了确定以后
          wx.showLoading({ title: '正在处理...', });
          app.visit('drinker/setRewardOrder', {
            ds_price:ds_price,
            user_id: wx.getStorageSync("user_id"),
            order_id:t.data.order_id
          }, 'POST',function (result) {
            console.error('支付',result);
            if(result.code == 0){
              // 发起微信支付
              wx.requestPayment({
                timeStamp: result.data.payTimeStamp,
                nonceStr: result.data.paynonceStr,
                package: result.data.payPackage,
                signType: 'RSA',
                paySign: result.data.paySign,
                success: function (res) {
                  wx.showToast({
                    title: '打赏成功',
                    icon: 'none',
                    success: function () {
                      setTimeout(function () {
                        wx.hideToast();
                      }, 1e3);
                    }
                  })
                }
              });
            }else{
              app.myToast('调取支付失败')
            }
            wx.hideLoading();
          });
        } else {//这里是点击了取消以后
          console.log('用户点击取消')
        }
      }
    })
  },

  shangjia:function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "../new/shangjia?id="+id
    });
  }

})